package com.factors.HuangHePing.SchoolTypeCount;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

public class SchoolTypePartitioner extends Partitioner<Text, IntWritable> {

    @Override
    public int getPartition(Text key, IntWritable value, int numPartitions) {
        String schoolType = key.toString().split("_")[0];

        if ("Public".equals(schoolType)) {
            return 0;
        } else if ("Private".equals(schoolType)) {
            return 1;
        } else {
            return (numPartitions - 1);
        }
    }
}